package com.dhcc.bpm.modules.gateway.service.impl;

import com.dhcc.bpm.modules.api.entity.Product;
import com.dhcc.bpm.modules.api.mapper.ProductMapper;
import com.dhcc.bpm.modules.common.vo.SelectVo;
import com.dhcc.bpm.modules.gateway.entity.Gateway;
import com.dhcc.bpm.modules.gateway.vo.GatewayVO;
import com.dhcc.bpm.modules.gateway.mapper.GatewayMapper;
import com.dhcc.bpm.modules.gateway.service.IGatewayService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.util.List;

/**
 * @ClassName GatewayServiceImpl
 * @Description 网关表 服务实现类
 * @Author YaoZC
 * @Date 2019/11/26 16:08
 * @Version 1.0
 * @Copyright: 2019 东华软件 . All rights reserved.
 */
@Service("opc_gateway")
public class GatewayServiceImpl extends BaseServiceImpl<GatewayMapper, Gateway> implements IGatewayService {
	@Autowired
	private ProductMapper productMapper;
	/**
	 * @Description 自定义分页
	 * @Date 2019/11/26 16:08
	 * @param page
	 * @param gateway
	 * @return java.util.List<com.dhcc.bpm.modules.gateway.vo.GatewayVO>
	 **/
	@Override
	public IPage<GatewayVO> selectGatewayPage(IPage<GatewayVO> page, GatewayVO gateway) {
        return page.setRecords(baseMapper.selectGatewayPage(page, gateway));
	}

	/**
	 * @Description 自定义分页
	 * @Date 2019/11/26 16:08
	 * @param page
	 * @param gateway
	 * @return java.util.List<com.dhcc.bpm.modules.gateway.vo.GatewayVO>
	 **/
	@Override
	public IPage<GatewayVO> selectGatewayList(IPage<GatewayVO> page, GatewayVO gateway) {
        return page.setRecords(baseMapper.selectGatewayList(page, gateway));
	}

	/**
	 * @Description 查询未分配的网关列表
	 * @Date 2019/11/26 16:08
	 * @param page
	 * @param gateway
	 * @return java.util.List<com.dhcc.bpm.modules.gateway.vo.GatewayVO>
	 **/
	@Override
	public IPage<GatewayVO> selectUnControllerGatewayList(IPage<GatewayVO> page, GatewayVO gateway) {
        return page.setRecords(baseMapper.selectUnControllerGatewayList(page, gateway));
	}

	/**
	 * @Description 刷新网关路由
	 * @Date 2019/11/26 16:08
	 * @param gateway
	 * @return int
	 **/
	@Override
	public int updateRefreshStatus(Gateway gateway) {
		return baseMapper.updateRefreshStatus(gateway);
	}

	/**
	 * @Description 根据网关ID查询产品列表
	 * @Date 2020/3/6 10:24
	 * @param page
	 * @param product
	 * @param gatewayId
	 * @return com.baomidou.mybatisplus.core.metadata.IPage<com.dhcc.bpm.modules.gateway.vo.GatewayVO>
	 **/
	@Override
	public IPage<Product> productListByGatewayId(IPage<Product> page, Product product, String gatewayId) {
		return page.setRecords(productMapper.productListByGatewayId(page, product,gatewayId));
	}

	/**
	 * @Description TODO
	 * @Author xiafayu
	 * @Date 2020/3/31 14:17
	 * @param  
	 * @return java.util.List<com.dhcc.bpm.modules.common.vo.SelectVo>
	 * @throws 
	 **/
	@Override
	public List<SelectVo> selectGatewayName() {
		return baseMapper.selectGatewayName();
	}

	@Override
	public List<String> selectGatewayNameById(String id) {
		return baseMapper.selectGatewayNameById(id);
	}

	@Override
	public String selectGatewayNameByCode(String code) {
		return baseMapper.selectGatewayNameByCode(code);
	}

}
